<include file="../Public/plugin.header.html" />

<link href="__PUBLIC__/Css/plugin-search.css" rel="stylesheet" type="text/css"  />
<style>
.sidebar {
    background: none repeat scroll 0 0 #E3EEF8;
}
</style>

<script type="text/javascript" src="http://api.map.baidu.com/api?v=1.2&services=true"></script>
<script type="text/javascript" src="__PUBLIC__/Js/kim.base.map.js"></script>
<script type="text/javascript">
/**
function resize(a,b){
	b = b-50;
	var c=Math.max(a-220,0);
	
	var temp = $("#sidebar").is(":hidden");//是否隐藏
	var temp1= $("#sidebar").is(":visible");//是否可见 
	if(temp||!temp1){
		c=Math.max(a,0);
	}
	$("#sidebar").css( {height: (b+1+"px") } );
	$("#g_plugin").css( {height: (Math.max(b,0)+"px") } );
	$("#map_warp").css( {width: (c+"px") } );
	$("#map_warp").css( {height: (b+"px") } );
	$("#map_container").css( {width: (c+"px") } );
	$("#map_container").css( {height: (b+"px") } );
	$("#FullScreen").css( {top: ((b/2)+"px") } );
	
	$("#info_list_container").css( {height: (Math.max(b-171,0)+"px") } );
	
	
	//$("#info_list_container").style.height=Math.max(b-161,0)+"px";
	//$("#map_container").style.width=c+"px";
	//$("#map_container").style.height=b+"px";
	//map.changeViewSize(new QQMap.QSize(c,b));adjustListWidth()
}
**/

$(document).ready(function(){
	//alert(1);
	resizeFull();
	window.onload=resizeFull;
	window.onresize=resizeFull;
	initMap("map_container","39.925","116.385",12);
	cleanAll();
	var store_infos = eval('( ' + $('#store_json_data').html() + ' )');
	store_markers = drawStoreMarkers(store_infos,marker_icon);
	
	//在地图上显示第一个店的信息框
	<php>if(count($partners)>0){ $_tmp_i = rand(0,count($partners)-1);echo $_tmp_i; </php>
	
	var _ttmp_marker = getStoreMarker( "{$partners[$_tmp_i].id}" );
	if(_ttmp_marker!=null){
		var _infoWindow = getStoreInfoWindow(new BMap.Size(0, _ttmp_marker.marker.getIcon().size.height*(-1) ),_ttmp_marker.storeinfo);
		_ttmp_marker.marker.openInfoWindow(_infoWindow);
	}
	<php>}</php>
	
	_initproduct();
});

/**
 * 返回店铺列表后，页面执行的初始化方法。
 */
function _initproduct(){
	$('#info_list').find('#gift_info').each(function(){
		//alert(333);
		$(this).hover(
				function(){
					//当鼠标放上去的时候,程序处理
					
					var brand_id = $(this).attr('rel');
					//alert(brand_id);
					var _ttmp_markers = getStoreMarkerByBrandId(brand_id);
					//alert(_ttmp_markers);
					var _ttmp_marker;
					if(_ttmp_markers.length>0){
						for(var i =0;i<_ttmp_markers.length;i++){
							_ttmp_marker = _ttmp_markers[i];
							_ttmp_marker.marker.setIcon(marker_icon_hover);
							var _infoWindow = getStoreInfoWindow(new BMap.Size(0, _ttmp_marker.marker.getIcon().size.height*(-1) ),_ttmp_marker.storeinfo);
							_ttmp_marker.marker.openInfoWindow(_infoWindow);
						}
					}
					$(this).addClass();
				},

				function(){
				   	//当鼠标离开的时候,程序处理
					var brand_id = $(this).attr('rel');
					var _ttmp_markers = getStoreMarkerByBrandId(brand_id);
					var _ttmp_marker;
					if(_ttmp_markers.length>0){
						for(var i =0;i<_ttmp_markers.length;i++){
							_ttmp_marker = _ttmp_markers[i];
							_ttmp_marker.marker.setIcon(marker_icon);
							//_ttmp_marker.marker.closeInfoWindow();
						}
					}
				}
		);
	});
}
function goPage(pno){
		$('#searchpform').find('#pno').val(pno);
		$('#searchpform').submit();
}

/**隐藏或显示左侧区域**/
function hidesidebar(obj_){
	var rel_ = $(obj_).attr('rel');
	//alert(rel_);
	if(rel_=='show'){
		$(obj_).attr('rel','hide');
		$('#sidebar').hide();
		
		$(obj_).css( { "background-position" : "-34px -250px" } );
		
		$(obj_).attr('title','打开左栏');
		$("#map_warp").css( { left : "0px",width:"100%" } );
		/****/
	}
	if(rel_=='hide'){
		$(obj_).attr('rel','show');
		$('#sidebar').show();
		
		$(obj_).css( { "background-position" : "0px -250px" } );
		
		$(obj_).attr('title','收起左栏');
		$("#map_warp").css( { left : "220px",width:"100%" } );
		/****/
	}
	resizeFull();
}
</script>

<!-- 保存json数据用于地图读取显示 -->
<div id="store_json_data" class="hidden">
		<php>
		if(count($partners)>0){
			echo json_encode( format2MapData($partners) );
		}
		</php>
</div>

<!-- 数据提交表单 -->
<form id='searchpform' action="{:U('plugin://gift/index')}" method="get">
  			<input type="hidden" name='popu_title' id='popu_title' value='{$popu_title}'>
			<input type="hidden" name='gifttype' id='gifttype' value='{$gifttype}'>
			<input type="hidden" name='pno' id='pno' value='1'>
</form>

<div>
	<div class="sidebar" id="sidebar" style="height: 591px;">
		<!-- 顶部 选择区 -->
		<div class="search_area" style="">
			<dt><strong>地点：</strong></dt>
	        <dd id="didian" class="">
	          <ul>
	            <li> <span class="<php>if($popu_title==''){</php>on<php>}</php>">
	            			<a href="javascript:void(0)" 
	            				onclick="$('#searchpform').find('#popu_title').val('');
	            								 k_changeGroupStyle('didian','ul > li > span ','','elect_on');
	            								 $('#searchpform').submit();" >
	            				全部
	            			</a></span> 
	            </li>
	            	<php>	
				    				foreach($populars as $vob){
				  	</php>
									  <li> <span class="<php>if($popu_title==$vob['title']){</php>on<php>}</php>">
									  			<a href="javascript:void(0)" 
									  				 onclick="$('#searchpform').find('#popu_title').val('{$vob['title']}');
									  				 					$('#searchpform').submit();" 
									  				 title="{$vob['title']}">{$vob['title']}</a></span> </li>
									 
				  	<php>	
				      		 	}
				  	</php>
	          </ul>
	        </dd>
		</div>
		<div class="info_container">
			<div class="nav_container">
				<ul id="category_list" class="category_list">
					<li class="yellow_tab<php>if($gifttype!='all'){</php>_behind<php>}</php>" onclick="$('#searchpform').find('#gifttype').val('all');$('#searchpform').submit();">全部</li>
					<li class="red_tab<php>if($gifttype!='chi'){</php>_behind<php>}</php>" onclick="$('#searchpform').find('#gifttype').val('chi');$('#searchpform').submit();">吃的</li>
					<li class="purple_tab<php>if($gifttype!='he'){</php>_behind<php>}</php>" onclick="$('#searchpform').find('#gifttype').val('he');$('#searchpform').submit();">喝的</li>
					<li class="blue_tab<php>if($gifttype!='wan'){</php>_behind<php>}</php>" onclick="$('#searchpform').find('#gifttype').val('wan');$('#searchpform').submit();">玩的</li>
					<!--  li class="green_tab_behind">乐的</li -->
					<li class="black_tab<php>if($gifttype!='other'){</php>_behind<php>}</php>" onclick="$('#searchpform').find('#gifttype').val('other');$('#searchpform').submit();">其他</li>
				</ul>
			</div>
			<div class="info_list_container" id="info_list_container">
				<ul style="display: block;" class="info_list" id="info_list">
				<volist id="vo" name="searchResult['data']">
				<li>
					<div class="gift_info" id="gift_info" rel="{$vo['partner_id']}" title="{$vo['goods_title']}  价格： {:formatMoney($vo['shelf_out_price'])}">
						<php>if($vo['goods_get_type']=='delivery'||$vo['goods_get_type']=='all'){</php><em class="peisong"><img src="__PUBLIC__/Images/global/icon_peisong.gif"></em><php>}</php>
				       	<a href="{:U('plugin://gift/show',array('shelfid'=>$vo['shelf_id']))}">
				       	<img width="80" height="80" alt="{$vo['goods_title']}" 
				       		src="{:getPhotoFromThumb($vo['goods_icon'],80,80)}">
				       	</a>
				       	<a href="{:U('plugin://gift/show',array('shelfid'=>$vo['shelf_id']))}">
				       		<p style="line-height:25px;height: 25px;overflow: hidden;">{$vo['goods_title']}</p></a>
				        {:formatMoney($vo['shelf_out_price'])}
				    </div>
				</li>
				</volist>
				</ul>
		    </div>
			<div class="pager_container">
				<div class="page_box_s fb">{$searchResult['html']}</div>
			</div>
		</div>
	</div>
	<div style="width: 100%;height: 591px;position: absolute;left: 220px;" id="map_warp">
		<div onclick="hidesidebar(this);" rel="show" 
			title="收起左栏" id="FullScreen" style="background-position: 0px -250px;"></div>
		<div style="width: 100%;height: 591px;" class="map_container" id="map_container"></div>
	</div>
</div>


<include file="../Public/plugin.footer.html" />